package com.example.demo.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * @author huangyuting
 */
public enum OperateTypeEnum {
    /**
     * 操作类型
     */
    ADD("新增","ADD"),
    DEL("删除","DEL"),
    READ("查询","READ"),
    EXPORT("导出","EXPORT"),
    IMPORT("导入","IMPORT"),
    COMMIT("提交","COMMIT"),
    BACK("回退","BACK"),
    EDIT("编辑","EDIT");
    private String name;
    private String value;

    OperateTypeEnum(String name, String value) {
        this.name = name;
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public String getValue() {
        return value;
    }

    public static String getNameByOperate(String operate) {
        if (StringUtils.isBlank(operate)) {
            return READ.getName();
        }
        for(OperateTypeEnum operateTypeEnum : values()) {
            if (operate.toUpperCase().contains(operateTypeEnum.getValue())) {
                return operateTypeEnum.getName();
            }
        }
        return READ.getName();
    }
}
